package com.me.mygdxgame;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector3;

public class Tutorial implements Screen, InputProcessor {

	final Egg game;
	OrthographicCamera camera;
	Texture rule;
	Texture moving;
	Texture createbird;
	Rectangle back;
	public Tutorial(final Egg ga) {
		// TODO Auto-generated constructor stub
		game = ga;
		camera = new OrthographicCamera();
		camera.setToOrtho(false, 800, 480);
		rule = new Texture(Gdx.files.internal("rule.png"));
		moving = new Texture(Gdx.files.internal("moving.png"));
		createbird = new Texture(Gdx.files.internal("createbird.png"));
		
		back = new Rectangle();
		back.x = 680;
		back.y = 30;
		back.height = 50;
		back.width = 100; 
	}
	@Override
	public void render(float delta) {
		// TODO Auto-generated method stub
		Gdx.gl.glClearColor(0, 0, 0.2f, 1);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        
        camera.update();
        game.batch.setProjectionMatrix(camera.combined);
		game.batch.begin();
		game.batch.draw(rule, 150, 250);
		game.batch.draw(createbird, 150, 170);
		game.batch.draw(moving, 150, 10);
		game.font.draw(game.batch, "Back", 680, 50);
		game.batch.end();
		
		Gdx.input.setInputProcessor(this);
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public boolean keyDown(int keycode) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean keyUp(int keycode) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean keyTyped(char character) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean touchDown(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		Vector3 vec = new Vector3();
    	vec.set(screenX,screenY,0);
		camera.unproject(vec);
    	if(back.contains(vec.x, vec.y))
    	{
    		game.setScreen(new MainMenuScreen(game));
    	}
		return false;
	}
	@Override
	public boolean touchUp(int screenX, int screenY, int pointer, int button) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean touchDragged(int screenX, int screenY, int pointer) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean mouseMoved(int screenX, int screenY) {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public boolean scrolled(int amount) {
		// TODO Auto-generated method stub
		return false;
	}

}
